package com.supcon.exchangedata.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * Created with IntelliJ IDEA.
 * 多线程定时任务配置类
 *
 * @Author: yangbin
 * @Date: 2022/03/16/14:14
 * @Description:
 */
@Configuration
@EnableAsync
public class AsyncConfig implements SchedulingConfigurer {

    @Autowired
    ThreadPoolTaskExecutor threadPoolTaskExecutor;


    @Override
    public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
        scheduledTaskRegistrar.setScheduler(Executors.newScheduledThreadPool(100, threadPoolTaskExecutor));
    }
}
